<template>
    <el-menu
            :default-active="defaultBlockid"
            class="el-menu-vertical-demo side-menu">
        <!-- <li v-for="（person, index） in persons"> {{ person.name }} </li>  -->

        <el-menu-item v-for="(block, findex) in blocks" :index="(block.id+'')" :key="findex">
            <i class="el-icon-menu"></i>
            <el-link :href="('../article/list?blockid='+block.id)" type="primary">{{block.title}}的文章</el-link>
        </el-menu-item>

        <el-menu-item>
            <el-link href="../article/list" type="primary">所有板块的文章</el-link>
        </el-menu-item>
    </el-menu>
</template>

<script>
    export default {
        name: "BlogSide",
        props: {
            defaultBlockid:String,
        },
        data() {
            return {
                blocks: undefined
            }
        },
        created(){
            this.refreshData(
                undefined,
                undefined,
                undefined,
                0,
                0,
                undefined,
            );
        },
        methods: {
            getListSuccessHandler(component, respData){
                component.blocks = respData.blocks;
            },
            refreshData(parentid, startpage, limit, edittimetype, prioritytype, status) {
                let reqData = {'parentid' : parentid,
                    'status' : status,
                    'priorityType' : prioritytype,
                    'editTimeType' : edittimetype,
                    'limit' : limit,
                    'startpage' : startpage,
                }

                this.CommonFunction.getDataFromResourceServer(
                    this,
                    "http://127.0.0.1:8081/blog/block/list",
                    reqData,
                    window.location.href,
                    false,
                    this.getListSuccessHandler,
                    this.CommonFunction.verifyFailRedirectOAuth2LoginHandler_Cms,
                    this.CommonFunction.otherFailBlankHandler
                )
            },
        },
    }
</script>

<style>
    .el-aside {
        text-align: center;
        height: 100%;
    }
    .side-menu{
        height: 100%;
    }
</style>